package com.example.order.intercept;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import feign.ResponseInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * openfeign的请求拦截器
 *
 * 对应的还有响应拦截器，对应接口为{@link ResponseInterceptor}
 *
 */
@Slf4j
@Component
public class XTokenRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate template) {
        log.info("添加请求token");
        // 添加请求头
        template.header("X-Token", "123456789");
    }
}
